using System;
using System.Collections.Generic;
using System.Text;
using Aspose.Pdf;
namespace Aspose_PDF_Creation
{
  //This class uses data supplied through properties to generate a PDF Form and save it in a file
  class CustomerPDF
  {
    //properties through which data values are fed into PDF document
    private string _FirstName;
    public string FirstName
    {
      get { return this._FirstName; }
      set { this._FirstName = value; }
    }

    private string _LastName;
    public string LastName
    {
      get { return this._LastName; }
      set { this._LastName = value; }
    }

    private string _Company;
    public string Company
    {
      get { return this._Company; }
      set { this._Company = value; }
    }

    private string _Address1;
    public string Address1
    {
      get { return this._Address1; }
      set { this._Address1 = value; }
    }

    private string _Address2;
    public string Address2
    {
      get { return this._Address2; }
      set { this._Address2 = value; }
    }

    private string _City;
    public string City
    {
      get { return this._City; }
      set { this._City = value; }
    }

    private string _State;
    public string State
    {
      get { return this._State; }
      set { this._State = value; }
    }

    private string _Zipcode;
    public string Zipcode
    {
      get { return this._Zipcode; }
      set { this._Zipcode = value; }
    }

    private string _Body;
    public string Body
    {
      get { return this._Body; }
      set { this._Body = value; }
    }

    //Method to generate PDF document
    public void Generate(string FileName)
    {

      //Create an instance of the Aspose.PDF class
      Pdf docPDF = new Pdf();

      //Add a section into the pdf document
      Section pdfSec1 = docPDF.Sections.Add();

      //Add a text element for the document header 
      Text pdfHeadText = new Text("Customer Information");

      //Define the text style for the header
      pdfHeadText.TextInfo.FontName = "Arial";
      pdfHeadText.TextInfo.IsTrueTypeFontBold = true;
      pdfHeadText.TextInfo.FontSize = 16;
      pdfHeadText.TextInfo.Alignment = AlignmentType.Center;
      pdfHeadText.TextInfo.LineSpacing = 5;
      pdfHeadText.TextInfo.TextBorder = new BorderInfo((int)BorderSide.All, 1.0F);
      pdfSec1.Paragraphs.Add(pdfHeadText);

      //Create a new table for the customer data
      Table pdfTab = new Table();
      pdfTab.Margin.Top = 10;
      pdfSec1.Paragraphs.Add(pdfTab);

      //Set with column widths of the table
      pdfTab.ColumnWidths = "80 200";

      //Create a default style for table text
      TextInfo pdfTabTextInf = new TextInfo();
      pdfTabTextInf.FontName = "Arial";
      pdfTabTextInf.FontSize = 10;
      pdfTabTextInf.LineSpacing = 3;
      pdfTab.DefaultCellTextInfo = pdfTabTextInf;


      //Create rows in the table for each data item and cells in the rows
      Row pdfRow1 = pdfTab.Rows.Add();
      pdfRow1.Cells.Add("FirstName:");
      pdfRow1.Cells.Add(_FirstName);

      Row pdfRow2 = pdfTab.Rows.Add();
      pdfRow2.Cells.Add("Surname:");
      pdfRow2.Cells.Add(_LastName);

      Row pdfRow3 = pdfTab.Rows.Add();
      pdfRow3.Cells.Add("Company:");
      pdfRow3.Cells.Add(_Company);

      Row pdfRow4 = pdfTab.Rows.Add();
      pdfRow4.Cells.Add("Address:");
      pdfRow4.Cells.Add(_Address1);

      Row pdfRow5 = pdfTab.Rows.Add();
      pdfRow5.Cells.Add("");
      pdfRow5.Cells.Add(_Address2);

      Row pdfRow6 = pdfTab.Rows.Add();
      pdfRow6.Cells.Add("City:");
      pdfRow6.Cells.Add(_City);

      Row pdfRow7 = pdfTab.Rows.Add();
      pdfRow7.Cells.Add("State:");
      pdfRow7.Cells.Add(_State);

      Row pdfRow8 = pdfTab.Rows.Add();
      pdfRow8.Cells.Add("Zipcode:");
      pdfRow8.Cells.Add(_Zipcode);
     
      //Save the document
      docPDF.Save(FileName);
    }
  }
}
